{include file='../public/header.html'}

	<div class="main">
		{include file='../public/left.html'}
		<div class="right">
			<nav aria-label="breadcrumb">
				<ol class="breadcrumb">
					<li class="breadcrumb-item"><a href="#">Home</a></li>
					<li class="breadcrumb-item"><a href="#">Library</a></li>
					<li class="breadcrumb-item active" aria-current="page">Data</li>
				</ol>
			</nav>
			<div class="main-content">
				<div class="card-">
                    <a href="/index/interes/schulte?type=5" class="btn btn-primary btn-sm">5*5</a>
                    <a href="/index/interes/schulte?type=6" class="btn btn-danger btn-sm">6*6</a>
                    <a href="/index/interes/schulte?type=8" class="btn btn-warning btn-sm">8*8</a>
                    <a href="/index/interes/schulte?type=10" class="btn btn-info btn-sm">10*10</a>
                </div>
                <div class="inter-page">
                	<p class="btn btn-primary btn-sm start_onkey" onclick="start_onkey(this)">开始游戏</p>
                    <center>
			            <table border=1>

			                {foreach $sequence as $key => $val name = foo}
			                	{if $smarty.foreach.foo.index % $type == 0}
									<tr> 
								{/if}
			                    <td onclick="onkey({$val},this)">{$val}</td>
			                {/foreach}
			            </table>

			        </center>
			        <div class="strip">
			        	<span class="min">00</span>
				        <b>:</b>
				        <span class="second">00</span>
				
				        <span class="millisecond">00</span>
			        </div>
                </div>
			</div>
		</div>
		<div class="alert alert-success" role="alert">...</div>
	</div>
	<script type="text/javascript">

		//舒尔特表
		var now_num = 1;
		var before_class = null;
		var max_num = {$type} * {$type};

		function onkey(num,_this)
		{
			//选择正确
			if(before_class != null){
				$(before_class).removeClass();
			}

			if(num == now_num){
				//完成
				if(num == max_num){
					end_onkey();
				}
				//当前数+1
				now_num++;
				//样式修改
				$(_this).addClass("correct");
			}else{
				$(_this).addClass("blunder");
			}

			before_class = _this;
		}


		//计时器
		var timer = "";
		var millisecond_num = 0;
		var second_num = 0;
		var min_num = 0;
		var onoff = true;

		

		//开始计时
		function start_time() {
		    if (onoff) {
		        onoff = false;
		        timer = setInterval(function() {
		            millisecond_num++;

		            if (millisecond_num <= 9) {
		                $(".millisecond").html(("0" + millisecond_num));
		            } else if (millisecond_num >= 10 && millisecond_num <= 99) {
		                $(".millisecond").html(millisecond_num);
		            } else if (millisecond_num >= 99) {
		                millisecond_num = 0;
		                second_num++;
		                $(".millisecond").html(("0" + millisecond_num));
		                if (second_num <= 9) {
		                    $(".second").html(("0" + second_num));
		                } else if (second_num >= 60) {
		                    second_num = 0;
		                    $(".second").html(("0" + second_num));
		                    min_num++;
		                    if (min_num <= 9) {
		                        $(".min").html(("0" + min_num));
		                    } else {
		                        $(".min").html(min_num);
		                    }
		                } else {
		                    $(".second").html((second_num));
		                }
		            }
		        }, 10)
		    }
		}

		//暂停
		function out_time() {
		    onoff = true;
		    clearInterval(timer);
		}

		//复位
		function reset_time() {
		    min_num = 0;
		    millisecond_num = 0;
		    second_num = 0;
		    clearInterval(timer);
		    $(".millisecond").html("00");
		    $(".second").html("00");
		    $(".rendom").html("0");
		    $(".min").html("00");
		    onoff = true;
		}

		//开始游戏
		function start_onkey(_this){
			$(_this).addClass('none');
			reset_time();
			now_num = 1;
			start_time()
		}

		//结束
		function end_onkey(){
			out_time();
			$('.start_onkey').removeClass('none');
		}

	</script>
{include file='../public/foot.html'}